import request from '@/utils/request'

//API常量
const APIS = {
    V1: "/v1"
}

export function listFiles(projectId) {
    return request({
        url: APIS.V1 + `/system/creditLoanFile/listFiles?projectId=`+projectId,
        method: 'GET'
    })
}

export function uploadFile(data) {
  return request({
    url: APIS.V1+`/system/creditLoanFile/uploadFile`,
    method: 'post',
    data
  })
}

// 批量保存附件信息
export function batchUpdateFile(data) {
  return request({
    url: APIS.V1+`/system/creditLoanFile/batchUpdateFile`,
    method: 'post',
    data
  })
}

// 查看项目附件列表
export function findDetailFile(data) {
  return request({
    url: APIS.V1+`/system/creditLoanFile/findDetailFile`,
    method: 'get',
    params:data
  })
}
// 删除附件（逻辑删除）
export function logicDelete(data) {
  return request({
    url: APIS.V1+`/system/creditLoanFile/logicDelete`,
    method: 'DELETE',
    params:data
  })
}

// 删除附件（物理删除 彻底删除）
export function physicalDeletion(data) {
  return request({
    url: APIS.V1+`/system/creditLoanFile/physicalDeletion`,
    method: 'DELETE',
    params:data
  })
}
// 批量下载文件
export function batchDownload(projectId) {
  return request({
    url: APIS.V1+`/system/creditLoanFile/batchDownload?projectId=`+projectId,
    method: 'POST',
    onDownloadProgress:(progressEvent) => { //原生获取上传进度的事件
      if(progressEvent.lengthComputable){
        return callback1(progressEvent);
      }
    },
    responseType: 'blob',
    timeout: 500000000 * 2,
  })
}

// export function creditLoanUploadFile(data) {
//   return request({
//     url: '/v1/system/creditLoanFile/uploadFile',
//     method: 'post',
//     data
//   })
// }

const creditLoanUploadFile = process.env.VUE_APP_BASE_API + '/v1/system/creditLoanFile/uploadFile'
export { creditLoanUploadFile }
